﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using MCMLXVII.BackEnd.Services.Common.Messages;
using MCMLXVII.BackEnd.Data.SystemDatabase;
using MCMLXVII.BackEnd.Pipeline;
using MCMLXVII.Core.Common.BackEnd;
using MCMLXVII.BackEnd.Data.SystemDatabase.DataSets;

#endregion

namespace MCMLXVII.BackEnd.Services.Core.BusinessActions
{
    public static class MultilingualContents
    {


        public static msgLanguajesListResponse GetContentLanguagesList(msgGenericItemRequest<bool> req)
        {

            bool ExcludeUserLang = req.Item;
            string ExcludeLang = "ZZZZZ";
            if (ExcludeUserLang) 
            {
                int MemberID = Security.GetMemberIDFromSession();
                ExcludeLang = MultiLingualContents.GetMemberLanguage(MemberID);
            }
            DSLocales.LocalesDataTable dt = MultiLingualContents.GetContentLocales();
            if ((dt == null) || (dt.Rows.Count == 0))
                return null;
            else
            {
                msgLanguajesListResponse resp = new msgLanguajesListResponse();
                foreach (DSLocales.LocalesRow row in dt.Rows)
                {
                    if (row.Language != ExcludeLang)
                        resp.AddLanguage(row.Language, row.Description);
                }
                return resp;
            }
        }

        public static string GetDefaultLanguage(msgVoidRequest req)
        {
            return MultiLingualContents.GetDefaultLanguage();
        }


    }
}
